{% macro build_line(b, include_builder=False) %}
  <small>({{ b.time }})</small>
  Rev: {{ b.rev|longrev(b.rev_repo) }}
  <span class="{{ b.class }}">{{ b.results }}</span>
  {% if include_builder %}
    <a href="{{ b.builderurl }}">{{ b.builder_name }}</a>
  {% endif %}
  <a href="{{ b.buildurl }}">#{{ b.buildnum }}</a> - 
  {{ b.text|capitalize }}
{% endmacro %}

{% macro build_tr(b, include_builder=False, loop=None, mastername=None) %}
  <tr class="{{ loop.cycle('alt', '') if loop }}">
    <td>{{ b.time }}</td>
    <td class="revision">{{ b.rev|longrev(b.rev_repo) }}</td>
    <td class="{{ b.class }}">{{ b.results }}</td>
  {%- if include_builder %}    
    <td><a href="{{ b.builderurl }}">{{ b.builder_name }}</a></td>
  {% endif %}
    <td><a href="{{ b.buildurl }}">#{{ b.buildnum }}</a>
      <div class="bbp_placeholder"
           id="{{ mastername }}:{{ b.builder_name }}:{{ b.buildnum }}"></div>
    </td>
    <td class="left">{{ b.text|capitalize }}</td>
  </tr>
{% endmacro %}

{% macro build_table(builds, include_builder=False, mastername=None) %}
{% if builds %}
<table class="info"> 
  <tr>
    <th>Time</th>
    <th>Revision</th>
    <th>Result</th>
     {%- if include_builder %}   
    <th>Builder</th>
     {% endif %}
    <th>Build #</th>
    <th>Info</th>
  </tr>
  {% for b in builds %}
    {{ build_tr(b, include_builder, loop, mastername=mastername) }}
  {% endfor %}
</table>
{% else %}
  No matching builds found
{% endif %}
{% endmacro %}
